import React from 'react'
import { inject, observer } from 'mobx-react'
import { PropTypes } from 'prop-types'
import Axios from 'axios'
import { AppState } from '../../store/appState'

function login() {
    Axios.post('/api/login?xxx=1111&needAccessToken=false', {
        accessToken: 'ef35af2e-95b4-4062-badc-419d3b'
    }).then(resp => {
        console.log(resp)
    }).catch(err => {
        console.log(err)
    })
}
@inject('appState') @observer
class TopicList extends React.Component {
    constructor() {
        super()
        this.state = {
            name: 'xxx'
        }
    }

    render() {
        const { name } = this.state
        const { appState } = this.props || {}
        return (
            <div>
                {appState.count} {name} TopicList detaile {appState.name} {appState.total}
                <div>
                    <button type="button" onClick={login}>登录</button>
                </div>
            </div>
        )
    }
}

export default TopicList

TopicList.propTypes = {
    appState: PropTypes.instanceOf(AppState)
}
TopicList.defaultProps = {

}
